import type { CategoryTopItem } from "@/types/category"
import type { LoginResult } from "@/types/member"
import { http } from "@/utils/http"

/**
 * 获取登录接口
 */

type LoginWxParams = {
  code:string
  encryptedData:string
  iv:string
}

// 小程序登录
export const postLoginWxMinAPI = (data:LoginWxParams) => {
  return http({
    method: 'POST',
    url: '/login/wxMin',
    data
  })
}

///login/wxMin/simple
/**
 * 模拟登录
 * @param phoneNumber
 * @returns
 */
export const postLoginWxMinSimpleAPI = (phoneNumber:string) => {
  return http({
    method: 'POST',
    url: '/login/wxMin',
    data: {
      phoneNumber
    }
  })
}

/**
 * 传统登录
 * @param phoneNumber
 * @returns
 */
export type LoginParams = {
  account: string
  password: string
}
export const postLoginAPI = (data:LoginParams) => {
  return http<LoginResult>({
    method: 'POST',
    url: '/login',
    data
  })
}
